/**
 * 学生端查看详情
 */
$(function(){
	var id = sessionStorage.getItem("id");
	$.ajax({
        url: "/huaqiao/front/teacher/getOneApply?id=" + id,
        async: false,
        success: function (str) {
            if (check(str)) {
                $("#hstudentname").val(str.studentname);
                $("#hstartTime").val(DateUtils.format(new Date(str.startTime), "yyyy-MM-dd HH:mm:ss"));
                $("#hendTime").val(DateUtils.format(new Date(str.endTime), "yyyy-MM-dd HH:mm:ss"));
                $("#apply-reason").val(str.requestReason);
                if(str.authStatus != 0){
            		document.getElementById("EleId2").style.visibility="hidden";
                	document.getElementById("EleId").style.visibility="hidden";
            		document.getElementById("EleId3").style.display="inline";
            		
            	}else{
            		document.getElementById("EleId2").style.display="visible";
            		document.getElementById("EleId").style.visibility="visible";
            		document.getElementById("EleId3").style.display="none";
            	}
                
            }
        }
    });
	 $.ajax({
	        url: "/huaqiao/StudentFront/getCurStu?" + new Date().getTime(),
	        async: false,
	        success: function (str) {
	            if (checkReturn(str)) {
	                $("#stu_name").text(str.name);
	                $("#class_name").text(str.classname);
	            }
	        }
	    });
 });
function editTourequest(){
	
	var id = sessionStorage.getItem("id");
        $.ajax({
        	type: "post",
            url: "/huaqiao/tourequest/modify?id=" + id,
            async: false,
            success: function (){
            	layer.msg("撤销成功！", {time: 1000});
            	window.setTimeout("window.location.href = 'apply.record_pc_student.html'",1000);
            }
        });
    }
function goBack() {
	window.history.go(-1);
}
function check(str) {
    if (str != null && str != "" || str == 0) {
        if (str.errorcode != undefined) {
            if (str.errorcode == 1) {
                if (islogin == 1) {
                    window.location.href = "/huaqiao/front_end/pc/student/login_pc_teacher.html";
                    islogin = 0;
                }
            }
            return false;
        } else {
            return true;
        }
    } else {
        return false;
    }
}
function checkReturn(str) {
    if (str != null && str != "") {
        if (str.errorcode != undefined) {
            if (str.errorcode == 1) {
                if (islogin == 1) {
                    alert(str.errormessage);
                    window.location.href = "login_pc_student.html";
                    islogin = 0;
                }
            }
            if (str.errorcode == 0) {
                alert(str.errormessage);
                return true;
            }
            return false;
        } else {
            return true;
        }
    } else {
        return false;
    }
}